package com.csd.action.teacher;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.csd.helper.ActionResult;
import com.csd.helper.IConstant;
import com.csd.service.IProjectService;
import com.csd.vo.UserVO;

/**
 * 
 * 教师对项目结题的审批Action类
 * @author 尹华彬
 * @version 1.0
 * 
 * <br> 修订时间：2009-12-17
 * <br> 修改原因：创建文件
 * <br> 修改人：尹华彬
 * 
 * <br> 
 * 
 */
public class TeacherFinishEvaluateAction {
	//项目ID
	private Integer  projectID;
	
	private IProjectService projectService;
	
	//结题申请 老师的结果
	private String result;
	
	public IProjectService getProjectService() 
	{
		return projectService;
	}

	public void setProjectService(IProjectService projectService) {
		this.projectService = projectService;
	}
 
	public Integer getProjectID() {
		return projectID;
	}

	public void setProjectID(Integer projectID) {
		this.projectID = projectID;
	}

	
	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}
	/**
	 * 老师对项目的结题申请的结果
	 * @return String
	 */
	public String execute()
	{
		String result = ActionResult.fail;
		Integer teacherID = null;
		//通过session获得teacherID	
		try 
		{
			HttpSession httpSession = ServletActionContext.getRequest().getSession();
			UserVO value = (UserVO)httpSession.getAttribute(IConstant.userVO);
			if(value == null)
			{
				throw  new Exception("用户未登录异常");
			}
			
			teacherID = value.getUserID();
		} 
		catch (Exception e) 
		{
			e.printStackTrace();
			return result;
		}
		
		if(teacherID == null)
			return result;
		
		//更新项目
		try 
		{
			projectService.updateProject(projectID , this.result);
		} catch (Exception e) 
		{
			e.printStackTrace();
		}
		result = ActionResult.success;
		return result;
	}
}
